/**
 * 
 */
	var curMenu = null, zTree_Menu = null;
	var zNodes =[];
			var setting = {
				view: {
					showLine: false,
					showIcon: false,
					selectedMulti: false,
					dblClickExpand: false,
					addDiyDom: addDiyDom
				},async : {
					enable : true,
					url : getUrl
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				callback: {
					//beforeClick: beforeClick,
					onClick : onClick
				}
			};
			/*function beforeClick(treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("treeDemo");
				zTree.expandNode(treeNode);
				return true;
			}*/
			function addDiyDom(treeId, treeNode) {
				var spaceWidth = 5;
				var switchObj = $("#" + treeNode.tId + "_switch"),
				icoObj = $("#" + treeNode.tId + "_ico");
				switchObj.remove();
				icoObj.before(switchObj);
				if (treeNode.level > 1) {
					var spaceStr = "<span style='display: inline-block;width:" + (spaceWidth * treeNode.level)+ "px'></span>";
					switchObj.before(spaceStr);
				}
			}
			function loadTree(projectId) {
				$.ajax({
					async : false,
					type : 'POST',
					dataType : "json",
					url :"/tree/initTree/"+projectId,//请求的action路径
					success : function(data) { //请求成功后处理函数。
					$.fn.zTree.init($("#treeDemo"), setting, data);
					$("#treeDemo").addClass("showIcon");
				}
			});
			}	
			//拼装获取字节点的url
			function getUrl(treeId, treeNode) {
				var param = "parentId=" + treeNode.id;
				if(treeNode.isParent){
					if("true"===treeNode.isLast){
						param+="&type=dm";
					}else{
						param+="&type=pm";
					}
				}
				return "/questions/getChildrenTrees?"+ encodeURI(param) + "&p="
						+ new Date();
			}
			//点击树出现右侧界面
			function onClick(event, treeId, treeNode) {
				var param;
				var type=treeNode.type;
				if("pm"===type){
					if(treeNode.isLast==="true"){
						param="id="+treeNode.id+"&nodeName="+treeNode.name+"&isLast="+treeNode.isLast+"&type=dm";
						param="/questions/getChildrenData?"+encodeURI(param)+"&timestamp="+new Date().getTime();		
					}
					else{
						param="id="+treeNode.id+"&nodeName="+treeNode.name+"&isLast="+treeNode.isLast+"&type=pm";
						param="/questions/getChildrenData?"+encodeURI(param)+"&timestamp="+new Date().getTime();				
					}
					$("#publiciframe").attr('src',param);
				}			
			}
			
			$(function(){
				//切换项目加载树
				$('#project').change(function(){
					loadTree($(this).val());
				});
				//页面颜色调整
				$("#bgcolor").bigColorpicker(function(el,color){
					$('#publiciframe').contents().find("body").css("background-color",color);
				});
				//加载树
				loadTree($('#project').val());
				$('#structure').attr("src","/html/"+$('#project').find('option:selected').attr('zip')+"/sns.html");
				
			});			
			
			function showData(e) {
				 var strdata="";
				 strdata+="<tr onclick='showselData(this);'><td>"+e.children[0].innerHTML+"</td><td>"+e.children[1].innerHTML+"</td>" +
						"<td>"+e.children[2].innerHTML+"</td><td>"+e.children[3].innerHTML+"</td>" +
						"<td>"+e.children[4].innerHTML+"</td><td style='display:none;'>"+e.children[5].innerHTML+"</td></tr>";
				document.getElementById("publiciframe").contentWindow.$("#row_data").append(strdata);
		        var parentElement = e.parentNode;
		        if(parentElement){
		               parentElement.removeChild(e);
		        }
			}
			
			function getData(){
				var mytable=document.getElementById("tb_data");
					    var data = [];
					    for(var i=0;i<$("#tb_data tr").size();i++){
					      for(var j=0;j<mytable.rows[i].cells.length;j++){
					        if(!data[i]){
					          data[i] = new Array();
					        }
					        data[i][j] = mytable.rows[i].cells[j].innerHTML;
					      }
					    }
				return data;
			}
			
			
			
			
			
			
			
			
			